package pta;

import java.util.Scanner;

/**
 * @author tmh
 * @date 2024/12/18 21:13
 * @description
 */
public class T6_55分数加减法类和对象 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String str = sc.next();
            char[] ch = str.toCharArray();

            int a = ch[0] - '0';
            int b = ch[2] - '0';
            int c = ch[4] - '0';
            int d = ch[6] - '0';

            Fs fs1 = new Fs(a, b);
            Fs fs2 = new Fs(c, d);

            Fs result = null;
            if (ch[3] == '+') {
                result = fs1.add(fs2);
            } else if (ch[3] == '-') {
                result = fs1.sub(fs2);
            }
            if (result.fz % result.fm == 0) {
                System.out.println(result.fz / result.fm);
            } else {
                System.out.println(result.fz + "/" + result.fm);
            }

        }
        sc.close();
    }
}

class Fs {
    int fz;
    int fm;

    public Fs() {
    }

    public int getFz() {
        return fz;
    }

    public void setFz(int fz) {
        this.fz = fz;
    }

    public int getFm() {
        return fm;
    }

    public void setFm(int fm) {
        this.fm = fm;
    }

    public Fs(int fz, int fm) {
        this.fz = fz;
        this.fm = fm;
    }

    public Fs add(Fs fs) {
        int resultFz = fz * fs.fm + fm * fs.fz;
        int resultFm = fm * fs.fm;
        return simple(resultFz, resultFm);
    }

    public Fs sub(Fs fs) {
        int resultFz = fz * fs.fm - fm * fs.fz;
        int resultFm = fm * fs.fm;

        return simple(resultFz, resultFm);
    }

    public Fs simple(int a, int b) {
        boolean flag = false;
        if (a == 0 || b == 0) {
            return new Fs(0, 1);
        }
        if (a < 0) {
            a = -1 * a;
            flag = true;
        }
        for (int i = a < b ? a : b; i > 1; i--) {
            if (a % i == 0 && b % i == 0) {
                a = a / i;
                b = b / i;
            }
        }
        if (flag) {
            return new Fs(-1 * a, b);
        } else {
            return new Fs(a, b);
        }
    }

}
